package com.ls.controller.rule;


import com.ls.controller.rule.model.*;
import com.ls.service.ISmsRuleService;
import com.ls.utils.ResultData;

import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;

import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @ClassName SmsRuleAppController
 * @Description app规则控制器
 * <p>
 * 短信规则，通话方式-规则 一对多 （不同规则不能包含相同的时间段）互斥 。规则-模板 一对多。 前端控制器
 * APP专用接口 数据库里面里面有一个默认模板
 * </p>
 *
 * @author pengyu
 * @since 2024-06-28
 */
@Api(value = "app规则相关接口", tags = "app规则相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/smsRuleApp")
public class SmsRuleAppController {

    private final ISmsRuleService service;

    /**
     * 分页查询短信规则
     */
    @GetMapping(value = "pageList")
    public ResultData pageList(QueryRuleModel model) {
        return service.pageList(model);
    }

    /**
     * 新增短信规则
     */
    @PostMapping(value = "add")
    public ResultData add(@Valid @RequestBody AddRuleModel model) {
        return service.add(model);
    }

    /**
     * 编辑短信规则
     */
    @PostMapping(value = "edit")
    public ResultData edit(@Valid @RequestBody EditRuleModel model) {
        return service.edit(model);
    }

    /**
     * 规则模板详情
     */
    @GetMapping(value = "/getRuleById")
    public ResultData getRuleById(Long ruleId) {
        return service.getRuleById(ruleId);
    }

    /**
     * 删除短信规则
     */
    @PostMapping(value = "del")
    public ResultData del(@RequestParam Long ruleId) {
        return service.del(ruleId);
    }

    /**
     * 通过id启用规则
     */
    @PostMapping(value = "bindRuleId")
    public ResultData bindRuleId(@Valid @RequestBody BindRuleIdModel model) {
        return service.bindRuleId(model);
    }
    /**一键开启规则*/
    @PostMapping(value = "openAllRule")
    public ResultData openAllRule(@Valid @RequestBody OpenAllRuleModel model){
        return service.openAllRule(model);
    }
}

